"""
目标：给定列表进行冒泡排序
    示例：sequence=[12,27,46,16,25,37,22,29,15,47,48,34]
"""


def bubble_sort(array):
    n = len(array)
    for i in range(n - 1):
        exchange = False
        for j in range(n - 1 - i):
            if array[j] > array[j + 1]:
                array[j], array[j + 1] = array[j + 1], array[j]
                exchange = True
        if exchange == False:
            break


sequence = [12, 27, 46, 16, 25, 37, 22, 29, 15, 47, 48, 34]
print(sequence)
bubble_sort(sequence)
print(sequence)
